# 导包
import unittest
import utils
from api.login_session import LoginAPI02
from parameterized import parameterized
import requests


# 封装测试类
class TestLoginAPI02(unittest.TestCase):

    # 前置处理
    def setUp(self) -> None:
        self.test_login_api = LoginAPI02()
        # 实例化session对象
        self.session = requests.session()

    # 后置处理
    def tearDown(self) -> None:
        self.session.close()

    # 测试用例
    @parameterized.expand(utils.read_db())
    def test01_login(self, login_data, status_code, success,  code, message):
        response = self.test_login_api.login_api(self.session, login_data)
        print(response.json())
        # 断言
        self.assertEqual(status_code, response.status_code)
        self.assertEqual(success, response.json().get("success"))
        self.assertEqual(code, response.json().get("code"))
        self.assertIn(message, response.json().get("message"))




























